#ifndef __OBJECT
#define __OBJECT

#include "libraries.h"
#include "gfxFunctions.h"

class Object
{
    protected:
        SDL_Surface *image;
        SDL_Rect pos; /* Keeps track of player location/hitbox size */
        string imgLocation;
        double dX, dY; /* Position in doubles for more accuracy. */

    public:
        SDL_Surface* getImage()  {return image;}
        SDL_Rect& getPos()       {return pos;  }
        int getX()               {return pos.x;}
        int getY()               {return pos.y;}
        int getW()               {return pos.w;}
        int getH()               {return pos.h;}
        double getCenterX(){return dX + 0.5 * pos.w;}
        double getCenterY(){return dY + 0.5 * pos.h;}
        double getDX()           {return dX;}
        double getDY()           {return dY;}
        string getImageLocation(){return imgLocation;}
        void setImage(string img){ imgLoad(image, img.c_str()); }
        void setImageAlpha(string img){ imgLoadAlpha(image, img.c_str()); }
        void setImageLocation(string img){ imgLocation = img;}
        void setPos(double x, double y)
        {
            dX    = x;
            dY    = y;
            updatePos();
        }
        void setPos(SDL_Rect& other)
        {
            dX = 1.0 * other.x;
            dY = 1.0 * other.y;
            updatePos();
        }
        void setX(double x)
        {
            dX    = x;
            updatePos();
        }
        void setY(double y)
        {
            dY = y;
            updatePos();
        }
        void setW(int w){pos.w = w;}
        void setH(int h){pos.h = h;}
        void setRect() /* Sets width and height of pos to image */
        {
            if(image) /* If image is not NULL */
            {
                pos.w = image->w;
                pos.h = image->h;
            }
            else
            {
                pos.w = 0;
                pos.h = 0;
            }
        }
        void draw(SDL_Surface*& screen){ if(image) SDL_BlitSurface(image, NULL, screen, &pos); }
        void updatePos()
        {
            pos.x = static_cast<int>(dX);
            pos.y = static_cast<int>(dY);
        }
};

#endif
